<HTML>
<HEAD>
  <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
  <TITLE>GerbMerge -- A Gerber-file merging program -- The Layout File</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff" LINK="#0000c0" VLINK="#8f008f">

<!-- -->

<P><FONT SIZE="+2">GerbMerge -- The Layout File</FONT></P>

<BLOCKQUOTE>
  <P><A HREF="http://claymore.engineer.gvsu.edu/~steriana"><FONT
   SIZE="-1">Andrew Sterian</FONT></A><FONT SIZE="-1"><BR>
  Padnos College of Engineering and Computing<BR>
  Grand Valley State University</FONT></P>
</BLOCKQUOTE>

<P><HR ALIGN=LEFT><TABLE WIDTH="100%" BORDER="0" CELLSPACING="2"
CELLPADDING="0">
  <TR>
    <TD><A HREF="index.html">Top-Level</A> | <A HREF="cfgfile.html">The Configuration File</A> | The Layout File | <A HREF="autosearch.html">Automatic Placement</A></TD>
  </TR>
</TABLE><HR ALIGN=LEFT></P>

<H2>Introduction</H2>

  <P>The layout file tells GerbMerge how to replicate and/or arrange the jobs that
  you specified in the <A HREF="cfgfile.html">configuration file</A>. The layout
  file must be specified when using manual relative placement. See the <A HREF="autosearch.html">Automatic
  Placement</A> page for an alternative to using the layout file approach.

  <P>The layout file is a plain text file that can be created with any
  text editor.

  <P>Have a look at the sample layout files <A HREF="layout1.def"><TT>layout1.def</TT></A>
  and <A HREF="layout2.def"><TT>layout2.def</TT></A> for a quick overview of this file.

<P><A NAME="RowsCols"></A>
<H2>Rows and Columns</H2>

<P>The panel layout is specified in terms of cells. Each cell is part of either a
row or column of cells. Each row or column can itself be a part of a column or row,
respectively. In this way, a large variety of layouts can be specified. Unfortunately,
this scheme is fairly easy to implement in code, but it does not allow for arbitrary
placement of jobs.

<P>At the top level, you specify the layout of the final panel by specifying the
contents of each row, from left to right. Let's begin with an example. The input job, named <TT>example</TT> is as follows:
<CENTER><IMG SRC="ex1.png"></CENTER>
We will place three copies of this job, all in a row, using the following layout:
<PRE>
  Row {
    example        # Jobs are listed in a row from left to right
    example
    example
  }
</PRE>
The above layout file leads to the following panel:
<CENTER><IMG SRC="ex1a.png"></CENTER>
<P>The <TT>Row { .... }</TT> construct indicates a single row of the layout. While you
can add spaces and comments as you please, the word <TT>Row</TT> and its associated
open-bracket must appear on one line, each job name on a separate line, and the closing
bracket on its own line. Thus, the following is illegal:
<PRE>
   Row { example example example }    # Illegal!
</PRE>

<P>The word <TT>Rotate</TT> following a job indicates that the given instance of the job
is to be rotated by 90 degrees at its current position. For example:
<PRE>
  Row {
    example
    example Rotate
    example
  }
</PRE>
The above layout file leads to the following panel:
<CENTER><IMG SRC="ex1b.png"></CENTER>

<P>Rows stack vertically beginning at the bottom of the panel and moving up. For example:
<PRE>
  Row {
    example
    example
    example
  }
  Row {
    example
    example
    example
  }
</PRE>
The above layout file leads to the following panel:
<CENTER><IMG SRC="ex1c.png"></CENTER>

<P>Suppose now that we want the two jobs on the right to be rotated so the final panel has
a smaller width, but larger height. We can try the following:
<PRE>
  Row {
    example
    example
    example Rotate
  }
  Row {
    example
    example
    example Rotate
  }
</PRE>
The above layout file leads to the following panel:
<CENTER><IMG SRC="ex1d.png"></CENTER>

<P>This layout is quite wasteful and not quite what we intended. The problem is that
GerbMerge stacks rows on top of each other based upon the highest job within a row. The
height of the first (bottom-most) row, then, is the height of the rotated job.
<P>What we really want is to
think of our layout in terms of columns (in this case). The first column should be two
jobs stacked on top of each other. The second column should be the same. While the third
column should be two jobs side by side. We can accomplish this effect by placing columns
within a single row. Within a column, jobs are listed in stacking order from bottom to top.
For example:
<PRE>
  Row {
    Col {
      example
      example
    }
    Col {
      example
      example
    }
    example Rotate
    example Rotate
  }
</PRE>
The above layout file leads to the following panel:
<CENTER><IMG SRC="ex1e.png"></CENTER>

<P>Study that layout file carefully. The panel has only a single row with 4 elements.
The first element is a column with two jobs. The second element (immediately to the
right of the first element) is also a column with two jobs. The third element is
a rotated job. The fourth and right-most element is a rotated job.

<P>In summary, a row is a list of cells that are laid out from left to right. A cell may
be a simple job, or it may be a column of jobs. The column is treated as a single row cell.

<P>Now, let's get fancy and embed a row within a column, like this:
<PRE>
  Row {
    Col {
      example
      Row {              # This row sits above a job, in a column.
        example Rotate   # These are laid out left to right in the
        example Rotate   # middle of a column.
      }
    }
    example Rotate       # These continue left to right in the main row
    example Rotate
  }
</PRE>
The above layout file leads to the following panel:
<CENTER><IMG SRC="ex1f.png"></CENTER>

<P>In words, the job consists of a single row. The first cell in the row is a column.
The first cell in the column is a job. Above this cell is another row, which has two
cells (rotated jobs) laid out left-to-right.

<P>Keep re-reading the above until it makes sense!

<P>Here's a quiz: how can you modify the layout file so that a non-rotated job is
added in the blank space at the top-right of the above panel? Think before proceeding.

<P>To add a job on top of the two rotated jobs at the right of the panel, we must
convert those two jobs into a column, like this:
<PRE>
  Row {
    Col {
      example
      Row {              # This row sits above a job, in a column.
        example Rotate   # These are laid out left to right in the
        example Rotate   # middle of a column.
      }
    }
    Col {
      Row {
        example Rotate
        example Rotate
      }
      example            # This job sits on top of the two rotated jobs
    }
  }
</PRE>
The above layout file leads to the following panel:
<CENTER><IMG SRC="ex1g.png"></CENTER>

<P>Once you get the hang of thinking in terms of recursive rows and columns, the
process is not all that difficult. There is one important rule to remember, however:
<CENTER><B>Columns can only be defined within a row, and rows can only be defined within
a column.</B></CENTER>

<P>Make sure you have a look at the sample layout files <A HREF="layout1.def"><TT>layout1.def</TT></A>
and <A HREF="layout2.def"><TT>layout2.def</TT></A> for more examples.

<H2>Rotation Angles</H2>
<P>For rotating jobs, most users will simply want to rotate jobs by 90 degrees (counterclockwise). This is achieved using the <TT>Rotate</TT> keyword as described above. It is also possible to rotate jobs by 180 and 270 degrees for special applications, for example, when panelized jobs are not completely separate but need to interact with each other.
<P>The full list of rotation keywords recognized in the layout file is as follows:
<UL>
<LI><TT>Rotate</TT>, <TT>Rotate90</TT>: rotate by 90 degrees counterclockwise</LI>
<LI><TT>Rotate180</TT>: rotate by 180 degrees</LI>
<LI><TT>Rotate270</TT>: rotate by 270 degrees counterclockwise</LI>
</UL>

<HR ALIGN=LEFT>
<P><CENTER><FONT SIZE="-1">&COPY; 2003-2008, Copyright by <A HREF="http://claymore.engineer.gvsu.edu/~steriana">Andrew
Sterian</A>; All Rights Reserved. mailto: <A HREF="mailto:steriana@claymore.engineer.gvsu.edu?subject=GerbMerge">steriana@claymore.engineer.gvsu.edu</A></FONT></CENTER>

</BODY>
</HTML>
